package cn.tedu._04mvcboot01.controller;

import cn.tedu._04mvcboot01.pojo.BMIDto;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class BMIController {

    /*
    @RequestMapping("/bmi")
    @ResponseBody
    public String bmi(Double height, Double weight){
        double result = weight / (height * height);
        if(result < 18.5){
            return "兄弟你瘦了";
        }
        if(result < 24){
            return "身体健康,大吉大利";
        }
        if(result < 27){
            return "你有点胖了";
        }
        return "重量级选手";
    }

     */

    @RequestMapping("/bmi")
    @ResponseBody
    public String bmi(BMIDto bmiDto){
        double height = bmiDto.getHeight();
        double weight = bmiDto.getWeight();
        double result = weight / (height * height);

        if(result < 18.5){
            return "兄弟你瘦了";
        }
        if(result < 24){
            return "身体健康,大吉大利";
        }
        if(result < 27){
            return "你有点胖了";
        }
        return "重量级选手";
    }
}
